package com.xiao.mall.message.service.mapper.front;

import com.xiao.mall.foundation.mapper.EntityMapper;
import com.xiao.mall.message.domain.UserNotification;
import com.xiao.mall.message.service.dto.front.UserNotificationFrontDto;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.ReportingPolicy;

@Mapper(componentModel = "spring",
        unmappedSourcePolicy = ReportingPolicy.IGNORE,
        unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface UserNotificationFrontMapper extends EntityMapper<UserNotificationFrontDto, UserNotification> {

    @Override
    UserNotification toEntity(UserNotificationFrontDto dto);

    @Override
    @Mappings({
            @Mapping(source = "notification.id", target = "notificationId"),
            @Mapping(source = "notification.type", target = "type"),
            @Mapping(source = "notification.topic", target = "topic"),
            @Mapping(source = "notification.target", target = "target"),
            @Mapping(source = "notification.title", target = "title"),
            @Mapping(source = "notification.content", target = "content"),
            @Mapping(source = "notification.targetType", target = "targetType"),
            @Mapping(source = "notification.action", target = "action"),
            @Mapping(target = "createdDate", dateFormat = "yyyy-MM-dd HH:mm:ss")
    })
    UserNotificationFrontDto toDto(UserNotification entity);
}
